@import './header';

.wunderbar__wrapper {
  flex: 1;
  max-width: 30rem;
  //margin-left: var(--spacing-s);
  margin-right: var(--spacing-s);

  &:hover {
    .wunderbar__input {
      outline: 2px solid var(--color-primary);
    }
  }
}

.wunderbar__wrapper--mobile {
  margin: 0;
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height-mobile);
  display: flex;
  align-items: center;
  width: 100%;

  .wunderbar {
    flex: 1;
  }

  .wunderbar__input {
    font-size: 16px; // https://stackoverflow.com/questions/2989263/disable-auto-zoom-in-input-text-tag-safari-on-iphone
    background-color: transparent;
    color: var(--color-text);
    border-radius: 0;
    margin-right: var(--spacing-l);

    &:focus {
      box-shadow: none;
    }
  }
}

.wunderbar {
  cursor: text;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 1;
  font-size: var(--font-small);
  height: var(--height-input);
  padding-left: var(--spacing-s);

  > .icon {
    top: 0;
    left: var(--spacing-s);
    height: 100%;
    position: absolute;
    z-index: 1;
    stroke: var(--color-input-placeholder);
  }

  @media (min-width: $breakpoint-small) {
    padding: 0;
  }
  @media (max-width: $breakpoint-small) {
    > .icon {
      left: 22px;
    }
  }
}

.wunderbar--inline {
  @extend .wunderbar;
  flex: 0;
  margin-right: 0;

  fieldset-section {
    width: 15rem;
  }

  @media (max-width: $breakpoint-small) {
    margin: var(--spacing-xxs) 0;
    padding-left: 0px;
    .icon {
      left: 11px;
    }
  }
}

.wunderbar__input {
  width: 100%;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  height: var(--height-input);
  border-radius: var(--border-radius);
  background-color: var(--color-input-bg);
  color: var(--color-input);
  padding-right: var(--spacing-s);
  padding-left: 2.2rem;
  -webkit-app-region: no-drag;
  border: 1px solid rgba(0, 0, 0, 0);

  &:focus {
    //border-radius: var(--border-radius);
    outline: 2px solid var(--color-primary) !important;
  }
}

.wunderbar__input--inline {
  @extend .wunderbar__input;
  @media (max-width: $breakpoint-small) {
    position: absolute;
    top: 0;
  }
  border-radius: var(--border-radius);
}

.wunderbar__suggestions {
  @extend .card;

  z-index: 3;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--header-height) - (var(--height-input)) + 22px);
  border-top: none;
  padding-top: var(--spacing-xs);
  background-color: var(--color-background);
  border-radius: 0 0 var(--border-radius) var(--border-radius);

  [data-highlighted] {
    .button {
      color: var(--color-primary-contrast) !important;
    }
    .wunderbar__suggestion-label {
      .wunderbar__suggestion-title,
      .wunderbar__suggestion-name {
        color: var(--color-primary-contrast) !important;
      }
    }
  }

  .wunderbar__more-results {
    font-size: var(--font-small);
    .button--link {
      color: var(--color-text-subtitle); // --color-odysee
      color: var(--color-brand); // --color-odysee
    }

    &:hover {
      .button--link {
        color: var(--color-brand-contrast) !important;
      }
    }
  }
}

.wunderbar__suggestions--mobile {
  top: calc(var(--header-height-mobile) - var(--spacing-xs));
  margin-top: var(--spacing-m);
  padding: var(--spacing-m) !important;
  overflow: visible;

  .wunderbar__bottom-links {
    .wunderbar__more-results {
      margin-left: 0;
      .button {
        padding-left: 0;
      }
      .wunderbar__tag-search {
        padding-right: 0;
      }
    }
  }

  .wunderbar__label {
    margin-left: 0;
  }

  li {
    margin-left: 0;
    .wunderbar__suggestion {
      margin-left: 0;
    }
  }
}

.wunderbar__top-claim {
  margin-bottom: var(--spacing-m);
}

.wunderbar__label {
  margin-bottom: var(--spacing-xs);
  margin-left: var(--spacing-m);
}

.wunderbar__top-separator {
  margin: var(--spacing-s) 0;
  width: 100%;
}

.wunderbar__suggestion {
  display: flex;
  align-items: center;
  padding: var(--spacing-s) 0;
  margin-left: var(--spacing-m);

  .media__thumb {
    flex-shrink: 0;
    overflow: hidden;
    $width: 5rem;
    @include handleClaimListGifThumbnail($width);
    width: $width;
    height: calc(#{$width} * (9 / 16));
    margin-right: var(--spacing-s);
  }

  @media (min-width: $breakpoint-small) {
    margin-left: var(--spacing-s);
  }
}

.wunderbar__suggestion--channel {
  .channel-thumbnail {
    @include handleChannelGif(calc(5rem * 9 / 16));
    margin-right: var(--spacing-xs);

    @media (min-width: $breakpoint-small) {
      @include handleChannelGif(calc(5rem * 9 / 16));
      margin-right: var(--spacing-s);
    }
  }
}

.wunderbar__suggestion-label {
  font-size: var(--font-small);
  min-width: 0;
  white-space: nowrap;
}

.wunderbar__suggestion-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.wunderbar__suggestion-name {
  @extend .help;
  margin-top: 0;
  color: var(--color-text);
}

.wunderbar__more-results {
  margin-left: var(--spacing-s);

  .button {
    padding: var(--spacing-s);
  }

  &:hover {
    .button {
      color: var(--color-primary-contrast);
    }
  }
}

.wunderbar__placeholder-suggestion {
  margin-bottom: var(--spacing-s);

  @media (min-width: $breakpoint-small) {
    padding-left: 0;
  }
}

.wunderbar__placeholder-label {
  width: 30%;
  height: 1rem;
  margin-top: var(--spacing-xs);
  @include placeholder;
}

.wunderbar__placeholder-thumbnail {
  width: 3rem;
  height: 3rem;

  @include placeholder;
}
.wunderbar__placeholder-info {
  width: 50%;
  height: 3rem;
  margin-left: var(--spacing-s);
  @include placeholder;
}

.wunderbar__mobile-search {
  @extend .button--alt;
  @extend .header__navigationItem--icon;
  padding: var(--spacing-xs);
  margin-right: var(--spacing-s);

  .button__label {
    color: var(--color-input-placeholder);
    opacity: 0.4;
  }

  @media (max-width: $breakpoint-small) {
    &:focus {
      box-shadow: none;
    }
  }
}

.wunderbar__tag-search {
  .tag {
    //display: flex;
    //align-items: center;
    height: 1.2rem;
    margin-left: var(--spacing-xxs);
    color: var(--color-brand-contrast);
    background-color: var(--color-brand);

    //padding-right:60px;
    padding-top: 1px;

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 11rem;
  }

  &:hover {
    .tag {
      background-color: var(--color-background);
      color: var(--color-text);
    }
  }
}

.wunderbar__bottom-links {
  display: flex;
  align-items: center;

  :first-child {
    flex: 1;
  }

  .wunderbar__more-results {
    margin-top: 0;
    margin-left: var(--spacing-xxs);
    margin-bottom: 0;

    @media (min-width: $breakpoint-small) {
      margin-bottom: 0;
    }
  }

  [data-reach-combobox-option]:last-of-type {
    margin-bottom: 0px;
  }
}

[data-reach-combobox-option] {
  padding: 0;
  border-radius: var(--border-radius);

  &:hover {
    color: var(--color-odysee-contrast);
    background-color: var(--color-brand);

    .wunderbar__suggestion-name {
      color: var(--color-brand-contrast);
    }
  }

  @media (min-width: $breakpoint-small) {
    margin-left: var(--spacing-xs);
    margin-right: var(--spacing-xs);
  }
}

[data-reach-combobox-option][data-highlighted] {
  background-color: var(--color-brand);
}

[data-reach-combobox-option][aria-selected='true'] {
  &:hover {
    background-color: var(--color-brand);
  }
}

[data-reach-combobox-option]:last-of-type {
  margin-bottom: var(--spacing-xs);
}
